package com.ruge.spring.cloud.gateway.util;

import org.springframework.util.AntPathMatcher;

import java.util.List;

/**
 * @author 嘿丷如歌
 * @version V1.0
 * @Description:
 * @date 2021/4/26 22:07
 */
public class UriMatchUtil {
    private static AntPathMatcher antPathMatcher = new AntPathMatcher();

    /**
     * url白名单匹配，处理配置中增加的特殊uri pattern
     *
     * @param patternList patternList
     * @param reqUri      reqUri
     * @return boolean
     */
    public static boolean patternUriMatch(List<String> patternList, String reqUri) {
        for (String p : patternList) {
            if (antPathMatcher.match(p, reqUri)) {
                return true;
            }
        }
        return false;
    }
}
